<?php
/**
 * Created by PhpStorm.
 * User: qttx
 * Date: 2019/5/30
 * Time: 13:56
 */
namespace app\api\controller;


use app\api\model\ComplaintModel;

class Complaint extends BaseController
{
    public function __construct()
    {
        parent::__construct();
        $this->complaint = new ComplaintModel();
    }

    /**投诉建议--添加**/
    public function complaint_add()
    {
        //$add['uid'] = $this->uid;
        $add['photo'] = request()->file('photo');
        $add['type'] = request()->post('type');
        if(empty($add['type']))
        {
            AjaxReturn('0','请选择投诉类型');
        }
        $add['content'] = request()->post('content');
        if(empty($add['content']))
        {
            AjaxReturn('0','投诉建议不能为空');
        }
        if(!empty($add['photo'])){
            $add['photo'] = $this->complaint->photo_add($add['photo']);//图片路径
        }else{
            $add['photo']='';
        }
        $add['createtime'] = time();
        $complaint_add = $this->complaint->complaint_add($add);

        if($complaint_add)
        {
            AjaxReturn('1','成功');
        }else{
            AjaxReturn('0','失败');
        }
    }


}